Skip to content

Commit

Permalink
[autoinstrumentation] Add node and pod ip env vars automatically (#2769)
Browse files Browse the repository at this point in the history
* Add node and pod ip env vars automatically

* Fix tests

* Fix tests

* Fix tests

* Fix tests

* Fix tests

* Update changelog
  • Loading branch information
TylerHelmuth authored Apr 2, 2024
1 parent aeb19a7 commit d672bc9
Show file tree
Hide file tree
Showing 31 changed files with 989 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .chloggen/include-node-ip-in-env-vars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: instrumentation

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Instrumentation now automatically add node and pod ips as env vars `OTEL_NODE_IP` and `OTEL_POD_IP` to instrumented containers.

# One or more tracking issues related to the change
issues: [2769]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ The value for `sampler.type` is added to the `OTEL_TRACES_SAMPLER` environment v
Valid values for `sampler.type` are defined by the [OpenTelemetry Specification for OTEL_TRACES_SAMPLER](https://opentelemetry.io/docs/concepts/sdk-configuration/general-sdk-configuration/#otel_traces_sampler).
The value for `sampler.argument` is added to the `OTEL_TRACES_SAMPLER_ARG` environment variable. Valid values for `sampler.argument` will depend on the chosen sampler. See the [OpenTelemetry Specification for OTEL_TRACES_SAMPLER_ARG](https://opentelemetry.io/docs/concepts/sdk-configuration/general-sdk-configuration/#otel_traces_sampler_arg) for more details.

The instrumentation will automatically inject `OTEL_NODE_IP` and `OTEL_POD_IP` environment variables should you need to reference either value in an endpoint.

The above CR can be queried by `kubectl get otelinst`.

Then add an annotation to a pod to enable injection. The annotation can be added to a namespace, so that all pods within
Expand Down
2 changes: 2 additions & 0 deletions pkg/constants/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const (

EnvPodName = "OTEL_RESOURCE_ATTRIBUTES_POD_NAME"
EnvPodUID = "OTEL_RESOURCE_ATTRIBUTES_POD_UID"
EnvPodIP = "OTEL_POD_IP"
EnvNodeName = "OTEL_RESOURCE_ATTRIBUTES_NODE_NAME"
EnvNodeIP = "OTEL_NODE_IP"

FlagApacheHttpd = "enable-apache-httpd-instrumentation"
FlagDotNet = "enable-dotnet-instrumentation"
Expand Down
Loading

0 comments on commit d672bc9

Please sign in to comment.