Skip to content

Commit

Permalink
[fix] only classic teams must provide a dataset header when sending m…
Browse files Browse the repository at this point in the history
…etrics (#127)

E&S environments are not *required* to set x-honeycomb-dataset header;
we have a fallback for them. Classic teams must provide a target dataset.
  • Loading branch information
robbkidd authored Sep 13, 2022
1 parent 87e7c71 commit 7e8f523
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion otlp/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (ri *RequestInfo) ValidateMetricsHeaders() error {
if len(ri.ApiKey) == 0 {
return ErrMissingAPIKeyHeader
}
if len(ri.Dataset) == 0 {
if ri.hasLegacyKey() && len(ri.Dataset) == 0 {
return ErrMissingDatasetHeader
}
if !IsContentTypeSupported(ri.ContentType) {
Expand Down
4 changes: 3 additions & 1 deletion otlp/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ func TestValidateMetricsHeaders(t *testing.T) {
}{
{name: "no key, no dataset", apikey: "", dataset: "", contentType: "", err: ErrMissingAPIKeyHeader},
{name: "no key, dataset present", apikey: "", dataset: "dataset", contentType: "", err: ErrMissingAPIKeyHeader},
// classic environments need to tell us which dataset to put metrics in
{name: "classic/no dataset", apikey: "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", dataset: "", contentType: "", err: ErrMissingDatasetHeader},
{name: "classic/dataset present", apikey: "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", dataset: "dataset", contentType: "application/protobuf", err: nil},
{name: "E&S/no dataset", apikey: "abc123DEF456ghi789jklm", dataset: "", contentType: "application/protobuf", err: ErrMissingDatasetHeader},
// dataset header not required for E&S, there's a fallback
{name: "E&S/no dataset", apikey: "abc123DEF456ghi789jklm", dataset: "", contentType: "application/protobuf", err: nil},
{name: "E&S/dataset present", apikey: "abc123DEF456ghi789jklm", dataset: "dataset", contentType: "application/protobuf", err: nil},
{name: "content-type/(missing)", apikey: "apikey", dataset: "dataset", contentType: "", err: ErrInvalidContentType},
{name: "content-type/javascript", apikey: "apikey", dataset: "dataset", contentType: "application/javascript", err: ErrInvalidContentType},
Expand Down

0 comments on commit 7e8f523

Please sign in to comment.