Skip to content

Commit

Permalink
Generate Export[Logs|Metrics|Traces]PartialSuccess, plugin into the R…
Browse files Browse the repository at this point in the history
…esponse

Signed-off-by: Bogdan <[email protected]>
  • Loading branch information
bogdandrutu committed Oct 20, 2022
1 parent 79d5c62 commit aeb4102
Show file tree
Hide file tree
Showing 32 changed files with 911 additions and 157 deletions.
8 changes: 6 additions & 2 deletions pdata/internal/cmd/pdatagen/internal/files.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal"

var commonFile = &File{
Path: "pdata",
Name: "common",
PackageName: "pcommon",
imports: []string{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal"

var logFile = &File{
Path: "pdata",
Name: "logs",
PackageName: "plog",
imports: []string{
`"sort"`,
``,
`"go.opentelemetry.io/collector/pdata/internal"`,
`otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1"`,
},
testImports: []string{
Expand Down
61 changes: 61 additions & 0 deletions pdata/internal/cmd/pdatagen/internal/plogotlp_structs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal"
import (
"path/filepath"
)

var logOtlpFile = &File{
Path: filepath.Join("pdata", "plog"),
Name: "logs_otlp",
PackageName: "plogotlp",
imports: []string{
`"sort"`,
``,
`"go.opentelemetry.io/collector/pdata/internal"`,
`otlpcollectorlog "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1"`,
},
testImports: []string{
`"testing"`,
``,
`"github.com/stretchr/testify/assert"`,
``,
`"go.opentelemetry.io/collector/pdata/internal"`,
`otlpcollectorlog "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1"`,
},
structs: []baseStruct{
exportLogsPartialSuccess,
},
}

var exportLogsPartialSuccess = &messageValueStruct{
structName: "ExportLogsPartialSuccess",
description: "// ExportLogsPartialSuccess represents the details of a partially successful export request.",
originFullName: "otlpcollectorlog.ExportLogsPartialSuccess",
fields: []baseField{
&primitiveField{
fieldName: "RejectedLogRecords",
returnType: "int64",
defaultVal: `int64(0)`,
testVal: `int64(13)`,
},
&primitiveField{
fieldName: "ErrorMessage",
returnType: "string",
defaultVal: `""`,
testVal: `"error message"`,
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal"

var metricsFile = &File{
Path: "pdata",
Name: "metrics",
PackageName: "pmetric",
imports: []string{
`"sort"`,
``,
`"go.opentelemetry.io/collector/pdata/internal"`,
`otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1"`,
},
testImports: []string{
Expand All @@ -28,7 +30,6 @@ var metricsFile = &File{
`"github.com/stretchr/testify/assert"`,
``,
`"go.opentelemetry.io/collector/pdata/internal"`,
`"go.opentelemetry.io/collector/pdata/internal/data"`,
`otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1"`,
`"go.opentelemetry.io/collector/pdata/pcommon"`,
},
Expand Down
62 changes: 62 additions & 0 deletions pdata/internal/cmd/pdatagen/internal/pmetricotlp_structs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal"

import (
"path/filepath"
)

var metricsOtlpFile = &File{
Path: filepath.Join("pdata", "pmetric"),
Name: "metrics_otlp",
PackageName: "pmetricotlp",
imports: []string{
`"sort"`,
``,
`"go.opentelemetry.io/collector/pdata/internal"`,
`otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1"`,
},
testImports: []string{
`"testing"`,
``,
`"github.com/stretchr/testify/assert"`,
``,
`"go.opentelemetry.io/collector/pdata/internal"`,
`otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1"`,
},
structs: []baseStruct{
exportMetricsPartialSuccess,
},
}

var exportMetricsPartialSuccess = &messageValueStruct{
structName: "ExportMetricsPartialSuccess",
description: "// ExportMetricsPartialSuccess represents the details of a partially successful export request.",
originFullName: "otlpcollectormetrics.ExportMetricsPartialSuccess",
fields: []baseField{
&primitiveField{
fieldName: "RejectedDataPoints",
returnType: "int64",
defaultVal: `int64(0)`,
testVal: `int64(13)`,
},
&primitiveField{
fieldName: "ErrorMessage",
returnType: "string",
defaultVal: `""`,
testVal: `"error message"`,
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ func (iss *primitiveSliceStruct) generateInternal(sb *bytes.Buffer) {
}

var primitiveSliceFile = &File{
Path: "pdata",
Name: "primitive_slice",
PackageName: "pcommon",
testImports: []string{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal"

var traceFile = &File{
Path: "pdata",
Name: "traces",
PackageName: "ptrace",
imports: []string{
Expand Down
62 changes: 62 additions & 0 deletions pdata/internal/cmd/pdatagen/internal/ptraceotlp_structs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal"

import (
"path/filepath"
)

var traceOtlpFile = &File{
Path: filepath.Join("pdata", "ptrace"),
Name: "traces_otlp",
PackageName: "ptraceotlp",
imports: []string{
`"sort"`,
``,
`"go.opentelemetry.io/collector/pdata/internal"`,
`otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1"`,
},
testImports: []string{
`"testing"`,
``,
`"github.com/stretchr/testify/assert"`,
``,
`"go.opentelemetry.io/collector/pdata/internal"`,
`otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1"`,
},
structs: []baseStruct{
exportTracePartialSuccess,
},
}

var exportTracePartialSuccess = &messageValueStruct{
structName: "ExportTracePartialSuccess",
description: "// ExportTracePartialSuccess represents the details of a partially successful export request.",
originFullName: "otlpcollectortrace.ExportTracePartialSuccess",
fields: []baseField{
&primitiveField{
fieldName: "RejectedSpans",
returnType: "int64",
defaultVal: `int64(0)`,
testVal: `int64(13)`,
},
&primitiveField{
fieldName: "ErrorMessage",
returnType: "string",
defaultVal: `""`,
testVal: `"error message"`,
},
},
}
1 change: 1 addition & 0 deletions pdata/internal/cmd/pdatagen/internal/resource_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal"

var resourceFile = &File{
Path: "pdata",
Name: "resource",
PackageName: "pcommon",
imports: []string{
Expand Down
Loading

0 comments on commit aeb4102

Please sign in to comment.