-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add additional event handlers #216
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
base: main
Are you sure you want to change the base?
Changes from 23 commits
abacda3
05ca0b9
c35934a
74692fe
7c417cd
4c34975
82538a2
3d9057f
0232247
6a0e4d7
127e27f
d7c31b6
5667830
894fd9c
01db940
254196f
daa2314
09ccffb
70623ca
19f3eff
ecd11fe
0346c2f
8dff6e9
ce1040c
d388844
a237e71
fadd728
148ea84
3e01435
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,10 +9,12 @@ | |
| // Copyright 2025 Datadog, Inc. | ||
|
|
||
| using System.Diagnostics; | ||
| using System.Text.Json.Nodes; | ||
| using Amazon.EventBridge; | ||
| using Amazon.EventBridge.Model; | ||
| using CloudNative.CloudEvents; | ||
| using CloudNative.CloudEvents.SystemTextJson; | ||
| using Datadog.Trace; | ||
| using Microsoft.Extensions.Logging; | ||
| using Microsoft.Extensions.Options; | ||
| using Saunter.Attributes; | ||
|
|
@@ -139,14 +141,26 @@ internal async Task PublishCloudEventAsync(CloudEvent cloudEvent) | |
| var data = formatter.EncodeStructuredModeMessage(cloudEvent, out _); | ||
| var jsonString = System.Text.Encoding.UTF8.GetString(data.Span); | ||
|
|
||
| if (Tracer.Instance.ActiveScope is not null) | ||
|
Collaborator
Author
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. This adds DSM support to the AWS publishing
Member
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. We never call
Member
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. |
||
| { | ||
| var jsonNode = JsonNode.Parse(jsonString)!; | ||
| new SpanContextInjector().InjectIncludingDsm(jsonNode, SetHeader, Tracer.Instance.ActiveScope.Span.Context, "eventbridge", cloudEvent.Type!); | ||
| jsonString = jsonNode.ToJsonString(); | ||
| } | ||
| else | ||
| { | ||
| Log.GenericWarning(logger, "Failure publishing event", null); | ||
|
jeastham1993 marked this conversation as resolved.
Outdated
|
||
| activity?.SetTag("dsm.injection_skipped", "no active scope"); | ||
| } | ||
|
|
||
| var response = await client.PutEventsAsync(new PutEventsRequest() | ||
| { | ||
| Entries = new List<PutEventsRequestEntry>(1) | ||
| { | ||
| new() | ||
| { | ||
| EventBusName = awsConfiguration.Value.EventBusName, | ||
| Source = $"{Environment.GetEnvironmentVariable("ENV") ?? "dev"}.users", | ||
| Source = $"{Environment.GetEnvironmentVariable("ENV") ?? "dev"}.print", | ||
| DetailType = cloudEvent.Type, | ||
| Detail = jsonString, | ||
| } | ||
|
|
@@ -171,4 +185,11 @@ internal async Task PublishCloudEventAsync(CloudEvent cloudEvent) | |
| throw; | ||
| } | ||
| } | ||
|
|
||
| private static void SetHeader(JsonNode jsonNode, string key, string value) | ||
| { | ||
| if (jsonNode["_datadog"] == null) jsonNode["_datadog"] = new JsonObject(); | ||
|
|
||
| jsonNode["_datadog"]![key] = value; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.