Skip to content

Commit

Permalink
Merge pull request #75 from nginxinc/ps-dev-otel
Browse files Browse the repository at this point in the history
Allow otel module directives
  • Loading branch information
puneetsarna authored Oct 10, 2023
2 parents 73c76f9 + 5eb9b13 commit 928942a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
18 changes: 18 additions & 0 deletions analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,24 @@ var directives = map[string][]uint{
ngxHTTPMainConf | ngxHTTPSrvConf | ngxHTTPLocConf | ngxConfTake1234,
ngxStreamMainConf | ngxStreamSrvConf | ngxConfTake1234,
},
"otel_exporter": {
ngxHTTPMainConf | ngxConfBlock | ngxConfNoArgs,
},
"otel_service_name": {
ngxHTTPMainConf | ngxConfTake1,
},
"otel_span_attr": {
ngxHTTPMainConf | ngxHTTPSrvConf | ngxHTTPLocConf | ngxConfTake2,
},
"otel_span_name": {
ngxHTTPMainConf | ngxHTTPSrvConf | ngxHTTPLocConf | ngxConfTake1,
},
"otel_trace": {
ngxHTTPMainConf | ngxHTTPSrvConf | ngxHTTPLocConf | ngxConfTake1,
},
"otel_trace_context": {
ngxHTTPMainConf | ngxHTTPSrvConf | ngxHTTPLocConf | ngxConfTake1,
},
"output_buffers": {
ngxHTTPMainConf | ngxHTTPSrvConf | ngxHTTPLocConf | ngxConfTake2,
},
Expand Down
3 changes: 3 additions & 0 deletions analyze_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ var mapBodies = map[string]mapParameterMasks{
"geoip2": {
defaultMasks: ngxConf1More,
},
"otel_exporter": {
defaultMasks: ngxConfTake1,
},
}

// analyzeMapBody validates the body of a map-like directive. Map-like directives are block directives
Expand Down
21 changes: 21 additions & 0 deletions analyze_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,27 @@ func TestAnalyzeMapBody(t *testing.T) {
},
term: ";",
},
"valid otel_exporter": {
mapDirective: "otel_exporter",
parameter: &Directive{
Directive: "endpoint",
Args: []string{"localhost:4317"},
Line: 5,
Block: Directives{},
},
term: ";",
},
"invalid otel_exporter": {
mapDirective: "otel_exporter",
parameter: &Directive{
Directive: "endpoint",
Args: []string{"localhost:4317", "localhost:1234"},
Line: 5,
Block: Directives{},
},
term: ";",
wantErr: &ParseError{What: "invalid number of parameters", BlockCtx: "otel_exporter"},
},
"missing semicolon": {
mapDirective: "map",
parameter: &Directive{
Expand Down

0 comments on commit 928942a

Please sign in to comment.