-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9684 from owncloud/collaboration_improved_tracing
feat: include additional metadata for tracing the collaboration service
- Loading branch information
Showing
9 changed files
with
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Enhancement: Tracing improvements in the collaboration service | ||
|
||
Uploads and downloads through the collaboration service will be traced. The openInApp request will also be linked properly with other requests in the tracing. | ||
In addition, the collaboration service will include some additional information in the traces. Filtering based on that information might be an option. | ||
|
||
https://github.com/owncloud/ocis/pull/9684 |
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
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,47 @@ | ||
package middleware | ||
|
||
import ( | ||
"net/http" | ||
|
||
"go.opentelemetry.io/otel/attribute" | ||
"go.opentelemetry.io/otel/trace" | ||
) | ||
|
||
// CollaborationTracingMiddleware adds a new middleware in order to include | ||
// more attributes in the traced span. | ||
// | ||
// In order not to mess with the expected responses, this middleware won't do | ||
// anything if there is no available WOPI context set in the request (there is | ||
// nothing to report). This means that the WopiContextAuthMiddleware should be | ||
// set before this middleware. | ||
func CollaborationTracingMiddleware(next http.Handler) http.Handler { | ||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
wopiContext, err := WopiContextFromCtx(r.Context()) | ||
if err != nil { | ||
// if we can't get the context, skip this middleware | ||
next.ServeHTTP(w, r) | ||
} | ||
|
||
span := trace.SpanFromContext(r.Context()) | ||
|
||
wopiMethod := r.Header.Get("X-WOPI-Override") | ||
|
||
wopiFile := wopiContext.FileReference | ||
wopiUser := wopiContext.User.GetId() | ||
|
||
attrs := []attribute.KeyValue{ | ||
attribute.String("ocis.wopi.sessionid", r.Header.Get("X-WOPI-SessionId")), | ||
attribute.String("ocis.wopi.method", wopiMethod), | ||
attribute.String("ocis.wopi.resource.id.storage", wopiFile.GetResourceId().GetStorageId()), | ||
attribute.String("ocis.wopi.resource.id.opaque", wopiFile.GetResourceId().GetOpaqueId()), | ||
attribute.String("ocis.wopi.resource.id.space", wopiFile.GetResourceId().GetSpaceId()), | ||
attribute.String("ocis.wopi.resource.path", wopiFile.GetPath()), | ||
attribute.String("ocis.wopi.user.idp", wopiUser.GetIdp()), | ||
attribute.String("ocis.wopi.user.opaque", wopiUser.GetOpaqueId()), | ||
attribute.String("ocis.wopi.user.type", wopiUser.GetType().String()), | ||
} | ||
span.SetAttributes(attrs...) | ||
|
||
next.ServeHTTP(w, r) | ||
}) | ||
} |
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
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