Skip to content

Conversation

@austinlparker
Copy link

This adds a new component for the anthropic receiver.

austinlparker and others added 2 commits August 5, 2025 12:17
Adds a new receiver component for collecting usage and cost metrics from
the Anthropic Admin API. This component supports:
- Usage metrics collection with configurable intervals and grouping
- Cost metrics collection with separate configuration
- Environment variable substitution for API key
- Advanced configuration options for fine-tuning

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
Adds a new receiver component for collecting usage and cost metrics from
the Anthropic Admin API. This component supports:

- Usage metrics collection via the metrics channel (token counts, API calls)
- Cost data collection via the logs channel (spending information)
- Configurable collection intervals and grouping options
- Environment variable substitution for API key
- No default lookback windows to avoid historical data collection

The receiver can be configured to group usage metrics by model, service tier,
workspace ID, and API key ID, while cost data can be grouped by workspace ID
and description.

Status set to 'development' so it only appears with dev feature flag enabled.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@austinlparker austinlparker requested a review from a team as a code owner August 5, 2025 20:29
Add required test fixtures for the translator tests:
- HPSF input configurations (with defaults and all properties)
- Expected collector config outputs

The tests verify that the component templates correctly generate
OpenTelemetry collector configurations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@austinlparker austinlparker changed the title Add anthropic receiver feat: add anthropic receiver Aug 5, 2025
@TylerHelmuth
Copy link
Contributor

As a general note about the receiver, I recommend following contrib's scrape pattern wherever possible. If we can add a metadata.yaml and use it to define the metrics and then use mdatagen to generate the metricsbuilder from the metadata.yaml we'll gain a lot of confidence in the component.

@austinlparker
Copy link
Author

Do you have an example of this? Given that the API shape is a bit unique, I'm not sure how much we can re-use existing stuff.

@TylerHelmuth
Copy link
Contributor

https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/kubeletstatsreceiver is a good scrape example of using mdatagen to control the metric accumulation but not the api calls.

@austinlparker
Copy link
Author

ok - please take a look at the updates i've made to https://github.com/honeycombio/anthropic-usage-receiver

- Add missing filter properties (models, service_tiers, workspace_ids, api_key_ids)
- Update usage_bucket_width description to document valid values (1m, 1h, 1d)
- Change cost_lookback_window default from 0s to 7d to match receiver defaults
- Add template mappings for new filter properties with conditional inclusion
…om template

- Update cost_lookback_window default in test expectation file to match new 7d default
- Remove optional filter fields from template output (models, service_tiers, workspace_ids, api_key_ids)
  as they should only appear when explicitly set by the user
- Rename parameter from collection_interval to usage_collection_interval
  to clearly distinguish it from cost_collection_interval
- Update template mapping to use the new parameter name
- Update test files to use the new parameter name
- Move usage.collection_interval to be under the usage config section
- Remove root-level collection_interval as it's now part of UsageConfig
- Update test expectations to match new structure
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you manually test this config in a collector to confirm it works?

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