-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add status code to OTLP grpc trace log
- Loading branch information
1 parent
0dc2268
commit 8c68c8d
Showing
5 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_utils.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include <grpcpp/grpcpp.h> | ||
|
||
#include "opentelemetry/sdk/version/version.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
|
||
namespace exporter | ||
{ | ||
namespace otlp | ||
{ | ||
namespace grpc_utils | ||
{ | ||
|
||
const char *grpc_status_code_to_string(::grpc::StatusCode status_code); | ||
|
||
} // namespace grpc_utils | ||
} // namespace otlp | ||
} // namespace exporter | ||
|
||
OPENTELEMETRY_END_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "opentelemetry/exporters/otlp/otlp_grpc_utils.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
|
||
namespace exporter | ||
{ | ||
namespace otlp | ||
{ | ||
namespace grpc_utils | ||
{ | ||
|
||
const char *grpc_status_code_to_string(::grpc::StatusCode status_code) | ||
{ | ||
switch (status_code) | ||
{ | ||
case GRPC_STATUS_OK: | ||
return "OK"; | ||
case GRPC_STATUS_CANCELLED: | ||
return "CANCELLED"; | ||
case GRPC_STATUS_UNKNOWN: | ||
return "UNKNOWN"; | ||
case GRPC_STATUS_INVALID_ARGUMENT: | ||
return "INVALID_ARGUMENT"; | ||
case GRPC_STATUS_DEADLINE_EXCEEDED: | ||
return "DEADLINE_EXCEEDED"; | ||
case GRPC_STATUS_NOT_FOUND: | ||
return "NOT_FOUND"; | ||
case GRPC_STATUS_ALREADY_EXISTS: | ||
return "ALREADY_EXISTS"; | ||
case GRPC_STATUS_PERMISSION_DENIED: | ||
return "PERMISSION_DENIED"; | ||
case GRPC_STATUS_UNAUTHENTICATED: | ||
return "UNAUTHENTICATED"; | ||
case GRPC_STATUS_RESOURCE_EXHAUSTED: | ||
return "RESOURCE_EXHAUSTED"; | ||
case GRPC_STATUS_FAILED_PRECONDITION: | ||
return "FAILED_PRECONDITION"; | ||
case GRPC_STATUS_ABORTED: | ||
return "ABORTED"; | ||
case GRPC_STATUS_OUT_OF_RANGE: | ||
return "OUT_OF_RANGE"; | ||
case GRPC_STATUS_UNIMPLEMENTED: | ||
return "UNIMPLEMENTED"; | ||
case GRPC_STATUS_INTERNAL: | ||
return "INTERNAL"; | ||
case GRPC_STATUS_UNAVAILABLE: | ||
return "UNAVAILABLE"; | ||
case GRPC_STATUS_DATA_LOSS: | ||
return "DATA_LOSS"; | ||
default: | ||
return "UNKNOWN"; | ||
} | ||
} | ||
|
||
} // namespace grpc_utils | ||
} // namespace otlp | ||
} // namespace exporter | ||
|
||
OPENTELEMETRY_END_NAMESPACE |