Skip to content
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

Datadog observability driver #998

Merged
merged 20 commits into from
Jul 19, 2024
Merged

Datadog observability driver #998

merged 20 commits into from
Jul 19, 2024

Conversation

cjkindel
Copy link
Contributor

Describe your changes

Add a Datadog observability driver that pushes observability traces to a Datadog agent.

Issue ticket number and link

@cjkindel cjkindel requested a review from a team July 18, 2024 19:45
@cjkindel cjkindel self-assigned this Jul 18, 2024
Copy link

codecov bot commented Jul 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@cjkindel cjkindel marked this pull request as ready for review July 18, 2024 20:17
Copy link
Member

@collindutter collindutter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks pretty good! I love how little work was needed to extend @dylanholmes's existing observability work.

)
span_processor: SpanProcessor = field(
default=Factory(
lambda self: BatchSpanProcessor(OTLPSpanExporter(endpoint=self.datadog_agent_endpoint + "/v1/traces")),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use f-string instead of string concatenation.

takes_self=True,
),
kw_only=True,
)
_tracer: Optional[Tracer] = None
_root_span_context_manager: Any = None

def _trace_provider_factory(self) -> TracerProvider:
attributes = {"service.name": self.service_name}
if self.service_version:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use explicit is not None check

attributes = {"service.name": self.service_name}
if self.service_version:
attributes["service.version"] = self.service_version
if self.deployment_env:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is not None

collindutter
collindutter previously approved these changes Jul 18, 2024
Copy link
Member

@collindutter collindutter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved but would still like @dylanholmes's eyes before merging.

dylanholmes
dylanholmes previously approved these changes Jul 18, 2024
Copy link
Contributor

@dylanholmes dylanholmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

Just one optional refactor opportunity

@@ -18,18 +18,28 @@

@define
class OpenTelemetryObservabilityDriver(BaseObservabilityDriver):
service_name: str = field(kw_only=True)
service_name: str = field(default="griptape", kw_only=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small refactoring opportunity: If we have a default here, then we don't really need it in GriptapeObservabilityDriver anymore (which also mean that we need to override trace_provider there too).

Though its fine by me if you don't want to do it in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed GriptapeCloud used a non-attribute trace_provider on purpose. If we are OK with GriptapeCloud using the OpenTelemetry tracer_provider, then happy to. Just not clear why it used its own trace_provider in the first place

Copy link
Contributor

@dylanholmes dylanholmes Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tracer_provider was just added GriptapeObservabilityDriver in order to work around some attrs awkwardness. The resource arg was left out because Griptape Cloud doesn't really need them, but they don't hurt either. I'd personally prefer simpler code

@cjkindel cjkindel dismissed stale reviews from dylanholmes and collindutter via 3080e81 July 18, 2024 23:40
dylanholmes
dylanholmes previously approved these changes Jul 18, 2024
Copy link
Contributor

@dylanholmes dylanholmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Thanks for the small refactor too

@cjkindel cjkindel merged commit 40959cd into dev Jul 19, 2024
13 checks passed
@cjkindel cjkindel deleted the feature/datadog-observability branch July 19, 2024 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants