-
Notifications
You must be signed in to change notification settings - Fork 22
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
[awsxrayexporter] Allow sending spans in otlp format with a new config #236
[awsxrayexporter] Allow sending spans in otlp format with a new config #236
Conversation
…ed spans to X-Ray Service
for i := 0; i < td.ResourceSpans().Len(); i++ { | ||
// 1. build a new trace with one resource span | ||
singleTrace := ptrace.NewTraces() | ||
td.ResourceSpans().At(i).CopyTo(singleTrace.ResourceSpans().AppendEmpty()) |
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.
Any reason here copy to a new trace?
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.
because I didn't find a function that takes resourcespans as the input and produce bytes. The only function i found is this MarshalTraces
, which takes trace as the input.
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.
I think you need to put them under traces, this is the format used by the export request protobuf.
Basically the protobuf schema has same structure for TracesDatat
and ExportTraceServiceRequest
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.
Can you try using ExportTraceServiceRequest
https://opentelemetry.io/docs/specs/otlp/#binary-protobuf-encoding I think it should work as well and is closer to otlp implementation, which may have some other information in the future.
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.
ExportTraceServiceRequest is the Orig
of Trace
, however Orig
is not being exposed publicly. there's a function as below, but as you can see, it's a private function.
func (ms Traces) getOrig() *otlpcollectortrace.ExportTraceServiceRequest {
return internal.GetOrigTraces(internal.Traces(ms))
}
exporter/awsxrayexporter/config.go
Outdated
@@ -30,6 +30,9 @@ type Config struct { | |||
// AWS client. | |||
MiddlewareID *component.ID `mapstructure:"middleware,omitempty"` | |||
|
|||
// X-Ray Export sends spans in its original otlp format to X-Ray Service when this flag is on | |||
TransitSpanInOtlpFormat bool `mapstructure:"transit_spans_in_otlp_format,omitempty"` |
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.
I am not sure this config name is accurate because strictly speaking we are not using otlp format. Server side is accepting base64 encoded protobuf binary where OTLP is passing the raw bytes are request body. I suggest we call it something like encode_to_otel_binary_base64
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.
I agree with the intention but I don't think exposing too much implementation details to users is helpful. All users need to know is that this flag enable them to send complete otlp format span to X-Ray, which contains more information than X-Ray format. Hence, i would still prefer keeping the name.
} | ||
|
||
// 4. build bytes into base64 and append with PROTOCOL HEADER at the beginning | ||
base64Str := otlpFormatPrefix + base64.StdEncoding.EncodeToString(bytes) |
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.
I suppose we are not checking the size of encoded document? Does cwagent config has translator on the batching processor config? Though I think number of spans in one resource span is configured by the batch processor inside application for instrumentation SDK https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#batch-span-processor @mxiamxia Batch processor in agent/collector only has impact on how many resource spans (which equals to documents) and exporter is already handling more than 50 documents.
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.
Yeah we don't check the size, would this cause any issue? I think as long as X-Ray Service can accept such size, we should be good.
Does cwagent config has translator on the batching processor config?
I'm not aware of that.
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.
injectIndexConfigIntoOtlpPayload(singleTrace.ResourceSpans().At(0), cfg) | ||
|
||
// 3. Marshal single trace into proto bytes | ||
bytes, err := ptraceotlp.NewExportRequestFromTraces(singleTrace).MarshalProto() |
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.
nit: we can call it b instead of bytes, bytes
is often https://pkg.go.dev/bytes
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.
LGTM
I'm not sure if those failures in workflow are related with the change? Seems like they are related to other plugins. |
90ec962
into
amazon-contributing:aws-cwa-dev
Description:
This PR adds a configuration
transit_spans_in_otlp_format
in X-Ray Exporter to allow customers to choose to send spans in otlp format.Testing:
unit-tests done.
tested with cloudwatch agent, by running a sample app in EKS and verified the data received in X-Ray contains
aws.xray.exporter.config.index_all_attributes
andaws.xray.exporter.config.indexed_attributes
.