-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(opentelemetry): replace plugin attribute with plugin metadata #11940
Merged
Revolyssup
merged 16 commits into
apache:master
from
Revolyssup:revolyssup/otel-metadata
Jan 28, 2025
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fa561a4
use metadata
Revolyssup ff5c6f0
refactor(opentelemetry): replace plugin attribute with plugin metadata
Revolyssup 61f20b6
refactor(opentelemetry): replace plugin attribute with plugin metadata
Revolyssup 464fee3
refactor(opentelemetry): replace plugin attribute with plugin metadata
Revolyssup 116f0fd
fix tests
Revolyssup 40021b2
fix function call
Revolyssup 75fce79
use metadata in test 3
Revolyssup 1ad7c5f
fix tests
Revolyssup b9574fb
add docs
Revolyssup 3c5f2ef
fix doc
Revolyssup 7453e2d
fix lint
Revolyssup fa3c91a
fix lint doc
Revolyssup 480b385
fix lint
Revolyssup 9134a92
fix security warning test
Revolyssup 7d18613
fix lint
Revolyssup f9cacc6
apply suggestions
Revolyssup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,33 +36,44 @@ The `opentelemetry` Plugin can be used to report tracing data according to the [ | |
|
||
The Plugin only supports binary-encoded [OLTP over HTTP](https://opentelemetry.io/docs/reference/specification/protocol/otlp/#otlphttp). | ||
|
||
## Static Configurations | ||
## Configurations | ||
|
||
By default, configurations of the Service name, tenant ID, collector, and batch span processor are pre-configured in [default configuration](https://github.com/apache/apisix/blob/master/apisix/cli/config.lua). | ||
|
||
To customize these values, add the corresponding configurations to `config.yaml`. For example: | ||
You can change this configuration of the Plugin through the endpoint `apisix/admin/plugin_metadata/opentelemetry` For example: | ||
|
||
```yaml | ||
plugin_attr: | ||
opentelemetry: | ||
trace_id_source: x-request-id # Specify the source of the trace ID, `x-request-id` or `random`. When set to `x-request-id`, | ||
# the value of the `x-request-id` header will be used as the trace ID. | ||
resource: # Additional resource to append to the trace. | ||
service.name: APISIX # Set the Service name for OpenTelemetry traces. | ||
collector: | ||
address: 127.0.0.1:4318 # Set the address of the OpenTelemetry collector to send traces to. | ||
request_timeout: 3 # Set the timeout for requests to the OpenTelemetry collector in seconds. | ||
request_headers: # Set the headers to include in requests to the OpenTelemetry collector. | ||
Authorization: token # Set the authorization header to include an access token. | ||
batch_span_processor: # Trace span processor. | ||
drop_on_queue_full: false # Drop spans when the export queue is full. | ||
max_queue_size: 1024 # Set the maximum size of the span export queue. | ||
batch_timeout: 2 # Set the timeout for span batches to wait in the export queue before | ||
# being sent. | ||
inactive_timeout: 1 # Set the timeout for spans to wait in the export queue before being sent, | ||
# if the queue is not full. | ||
max_export_batch_size: 16 # Set the maximum number of spans to include in each batch sent to the OpenTelemetry collector. | ||
set_ngx_var: false # Export opentelemetry variables to nginx variables. | ||
:::note | ||
You can fetch the `admin_key` from `config.yaml` and save to an environment variable with the following command: | ||
|
||
```bash | ||
admin_key=$(yq '.deployment.admin.admin_key[0].key' conf/config.yaml | sed 's/"//g') | ||
``` | ||
|
||
::: | ||
|
||
```shell | ||
curl http://127.0.0.1:9180/apisix/admin/plugin_metadata/opentelemetry -H "X-API-KEY: $admin_key" -X PUT -d ' | ||
{ | ||
"trace_id_source": "x-request-id", | ||
"resource": { | ||
"service.name": "APISIX" | ||
}, | ||
"collector": { | ||
"address": "127.0.0.1:4318", | ||
"request_timeout": 3, | ||
"request_headers": { | ||
"Authorization": "token" | ||
}, | ||
"batch_span_processor": { | ||
"drop_on_queue_full": false, | ||
"max_queue_size": 1024, | ||
"batch_timeout": 2, | ||
"inactive_timeout": 1, | ||
"max_export_batch_size": 16 | ||
}, | ||
"set_ngx_var": false | ||
} | ||
}' | ||
``` | ||
|
||
Reload APISIX for changes to take effect. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really need reload now? |
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this change?