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

Add otlp exporters #89

Merged
merged 15 commits into from
Oct 3, 2023
Merged

Add otlp exporters #89

merged 15 commits into from
Oct 3, 2023

Conversation

actualwitch
Copy link
Contributor

@actualwitch actualwitch commented Sep 19, 2023

@actualwitch actualwitch marked this pull request as ready for review September 25, 2023 07:08
@brettimus
Copy link
Collaborator

when you have a chance could you document how to run the otlp example somewhere?

src/autometrics/decorator.py Show resolved Hide resolved
if ["otlp-proto-http", "otlp-proto-grpc"].count(exporter_options["type"]) > 0:
return OTLPExporterOptions(
type=exporter_options["type"],
endpoint=exporter_options["endpoint"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this (and other configuration lines) use safe accessors + have a default? i don't think it's guaranteed to be defined

alternatively, we could merge it with a default dict, to avoid fallback madness

Copy link
Contributor Author

Choose a reason for hiding this comment

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

most of these are marked as Optional so it's ok if they are just forwarded as None's. i'm pretty sure they all also have defaults/not requred

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah i see what's happening - i had to add the whole get_exporter_settings function to make it type typeddicts correctly but this now requires all fields to be filled. i'll look into refactoring this in a more sane way

Copy link
Collaborator

Choose a reason for hiding this comment

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

right on, your latest changes fixed it! as far as i can tell, the option names are the same between our library and the otel one for the otlp exporter, so it might be good to drop a link to their documentation somewhere for available options? if any thing just for our future selves

from autometrics import autometrics, init

init(
exporter={
Copy link
Collaborator

Choose a reason for hiding this comment

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

so i needed to fill in all fields like this to get things working (related to my comment about providing defaults for the exporter config):

    exporter={
        "type": "otlp-proto-http",
        "endpoint": "http://localhost:4318/v1/metrics",
        "insecure": True,
        "headers": None,
        "credentials": None,
        "push_interval": 1000,
        "timeout": 1000,
        "preferred_temporality": None,
    },

@actualwitch
Copy link
Contributor Author

I resolved the typing issues by using pydantic for runtime type checking, and added some examples for exporters. also, bumped our fastapi example

@actualwitch actualwitch force-pushed the otlp-exporter branch 5 times, most recently from a850213 to 67482f2 Compare September 27, 2023 21:22
docker-compose.yaml Outdated Show resolved Hide resolved
docker-compose.yaml Outdated Show resolved Hide resolved
configs/otel-collector-config.yaml Show resolved Hide resolved
@actualwitch actualwitch merged commit 5579b02 into main Oct 3, 2023
@actualwitch actualwitch deleted the otlp-exporter branch October 3, 2023 11:46
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.

2 participants