72
72
73
73
To override more instrumentation, add another entry in the ` config ` map.
74
74
75
+ #### Overriding configuration for specific instrumentation libraries with environment variables
76
+
77
+ You can also disable specific instrumentation libraries using environment
78
+ variables. An instrumentation disabled by an environment variable takes
79
+ precedence over local config. The convention for environment variable names is
80
+ the library name, upcased with ` :: ` replaced by underscores, ` OPENTELEMETRY `
81
+ shortened to ` OTEL_LANG ` , and ` _ENABLED ` appended.
82
+
83
+ For example, the environment variable name for
84
+ ` OpenTelemetry::Instrumentation::Sinatra ` is
85
+ ` OTEL_RUBY_INSTRUMENTATION_SINATRA_ENABLED ` .
86
+
87
+ ``` bash
88
+ export OTEL_RUBY_INSTRUMENTATION_SINATRA_ENABLED=false
89
+ ```
90
+
75
91
### Configuring specific instrumentation libraries
76
92
77
93
If you prefer more selectively installing and using only specific
@@ -98,6 +114,35 @@ OpenTelemetry::SDK.configure do |c|
98
114
end
99
115
```
100
116
117
+ #### Configuring specific instrumentation libraries with environment variables
118
+
119
+ You can also define the option for specific instrumentation libraries using
120
+ environment variables. By convention, the environment variable will be the name
121
+ of the instrumentation, upcased with ` :: ` replaced by underscores,
122
+ ` OPENTELEMETRY ` shortened to ` OTEL_{LANG} ` , and ` _CONFIG_OPTS ` appended.
123
+
124
+ For example, the environment variable name for
125
+ ` OpenTelemetry::Instrumentation::Faraday ` is
126
+ ` OTEL_RUBY_INSTRUMENTATION_FARADAY_CONFIG_OPTS ` . A value of
127
+ ` peer_service=new_service;span_kind=client ` overrides the options set from
128
+ [ previous section] ( #configuring-specific-instrumentation-libraries ) for Faraday.
129
+
130
+ ``` bash
131
+ export OTEL_RUBY_INSTRUMENTATION_FARADAY_CONFIG_OPTS=" peer_service=new_service;span_kind=client"
132
+ ```
133
+
134
+ The following table lists the acceptable format for values according to the
135
+ option data type:
136
+
137
+ | Data Type | Value | Example |
138
+ | --------- | -------------------------- | ---------------- |
139
+ | Array | string with ` , ` separation | ` option=a,b,c,d ` |
140
+ | Boolean | true/false | ` option=true ` |
141
+ | Integer | string | ` option=string ` |
142
+ | String | string | ` option=string ` |
143
+ | Enum | string | ` option=string ` |
144
+ | Callable | not allowed | N\A |
145
+
101
146
### Next steps
102
147
103
148
Instrumentation libraries are the easiest way to generate lots of useful
0 commit comments