Comments (9)
Hi @jeanbisutti, thanks for your help. The requirement to capture request payload has been deprioritized. Will reach out when it gets prioritized again.
Closing this ticket for now.
Thanks.
from applicationinsights-java.
Hi @avdhut1990!
You can use the Restlet instrumentation libraries with the Application Insights Java agent
from applicationinsights-java.
Hi @jeanbisutti, I have added the opentelemetry restlet dependencies in application in addition to the existing auto-instrumentation using app insights agent. Do I need perform any additional steps?
Thanks.
from applicationinsights-java.
Hi @jeanbisutti, I have added the opentelemetry restlet dependencies in application in addition to the existing auto-instrumentation using app insights agent. Do I need perform any additional steps?
Thanks.
You can have a look at the examples of the test folder, for example for Restlet 2: https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/restlet/restlet-2.0/library/src/test/groovy/io/opentelemetry/instrumentation/restlet/v2_0
from applicationinsights-java.
Hi @jeanbisutti ,
I have added the RestletTelemetryBuilder and StatusFilter code to the following method as per the example, however still not getting the requests captured in app insights. Do note that the application is already instrumented using app insights java agent and is able to capture traces and dependencies. Only requests are not getting captured.
package com.msci.esg.dataservice.restlet;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import com.msci.esg.dataservice.collaborators.usermanagement.UserManagementClientFactory;
import com.msci.esg.dataservice.screening.ChangeReportGenerator;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.security.keyvault.secrets.SecretClientBuilder;
import com.azure.storage.blob.BlobServiceClientBuilder;
import com.msci.esg.dataservice.CollaboratorClient;
import com.msci.esg.dataservice.azure.appconfig.AzureAppConfigInfo;
import com.msci.esg.dataservice.azure.appconfig.AzureAppConfigStorer;
import com.msci.esg.dataservice.azure.storage.AdlsStorage;
import com.msci.esg.dataservice.collaborators.wsdata.WSDataClient;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.instrumentation.restlet.v2_0.RestletTelemetry;
import org.apache.commons.lang3.SystemUtils;
import org.restlet.Application;
import org.restlet.Component;
import org.restlet.Restlet;
import org.restlet.Server;
import org.restlet.data.Protocol;
import org.restlet.data.Reference;
import org.restlet.engine.application.StatusFilter;
import org.restlet.resource.Directory;
import org.restlet.routing.Redirector;
import org.restlet.routing.Router;
import com.msci.esg.dataservice.collaborators.capture.CaptureClientFactory;
import com.msci.esg.dataservice.collaborators.princexml.PrinceXMLClientFactory;
import com.msci.esg.dataservice.collaborators.wsdata.WSDataClientFactory;
import com.msci.esg.dataservice.config.ConfigurationManager;
import com.msci.esg.dataservice.config.GlobalConfigCache;
import com.msci.esg.dataservice.types.ESGDataServicesConfig;
import com.msci.esg.dataservice.types.ServerLocation;
import com.msci.esg.dataservice.utils.LogRecorder;
import org.restlet.service.StatusService;
public class ESGDataServiceApplication extends Application {
private static final LogRecorder auditer; static { auditer = LogRecorder.logger(); }
private static Component component = null;
private final String serviceHost;
private final int servicePort;
private final boolean omitPort;
private boolean streamResults;
public static final String RESTLET_HTTP_HEADERS= "org.restlet.http.headers";
@Override
public synchronized Restlet createInboundRoot() {
final Router router = new Router(getContext());
router.attach("/query", streamResults ? StreamingQueryResource.class : QueryResource.class);
router.attach("/report", ReportResource.class);
router.attach("/home", HomeResource.class);
router.attach("/systemInfo", SystemInfoResource.class);
router.attach("/post", PostResource.class);
router.attach("/post/{name}", PostResource.class);
router.attach("/query/{name}", streamResults ? StreamingPostPageQueryResource.class : PostPageQueryResource.class);
router.attach("/itemImport", ItemImportResource.class);
router.attach("/stream", StreamResource.class);
RestletTelemetry telemetry = RestletTelemetry.builder(GlobalOpenTelemetry.get()).build();
StatusFilter statusFilter = new StatusFilter(component.getContext(), new StatusService());
telemetry.newFilter("/query").setNext(statusFilter);
telemetry.newFilter("/report").setNext(statusFilter);
telemetry.newFilter("/home").setNext(statusFilter);
telemetry.newFilter("/systemInfo").setNext(statusFilter);
telemetry.newFilter("/post").setNext(statusFilter);
telemetry.newFilter("/post/{name}").setNext(statusFilter);
telemetry.newFilter("/query/{name}").setNext(statusFilter);
telemetry.newFilter("/itemImport").setNext(statusFilter);
telemetry.newFilter("/stream").setNext(statusFilter);
statusFilter.setNext(router);
String rootPath;
try {
File file = new File(".");
rootPath = file.getCanonicalPath();
} catch (IOException e) {
throw new RuntimeException(e);
}
if(SystemUtils.IS_OS_WINDOWS) {
Directory directory = new Directory(getContext(), new Reference("file:\\\\" + rootPath + "\\images"));
router.attach("/images", directory);
} else {
Directory directory = new Directory(getContext(), new Reference("file://" + rootPath + "/images"));
router.attach("/images", directory);
}
String hostUriForClients = serviceHost + (omitPort ? "" : ":" + servicePort);
final String target = hostUriForClients + "/home";
final Redirector redirector = new Redirector(getContext(), target, Redirector.MODE_CLIENT_TEMPORARY);
router.attach("/", redirector);
return router;
}
}
from applicationinsights-java.
Hi @avdhut1990
In the Restlet examples I can see that the result of telemetry.newFilter
is returned (see this example and this example). Could you try in this way?
from applicationinsights-java.
Hi @jeanbisutti ,
Following code worked:
private synchronized void attachRoutes(RestletTelemetry telemetry, Router router, String path,
Class<? extends ServerResource> targetClass) {
Filter routeTelemetryFilter = telemetry.newFilter(path);
StatusFilter statusFilter = new StatusFilter(component.getContext(), new StatusService());
statusFilter.setNext(targetClass);
routeTelemetryFilter.setNext(statusFilter);
router.attach(path, routeTelemetryFilter);
}
@Override
public synchronized Restlet createInboundRoot() {
final Router router = new Router(getContext());
RestletTelemetry telemetry = RestletTelemetry.builder(GlobalOpenTelemetry.get()).build();
attachRoutes(telemetry, router, "/query", streamResults ? StreamingQueryResource.class : QueryResource.class);
attachRoutes(telemetry, router, "/report", ReportResource.class);
attachRoutes(telemetry, router, "/home", HomeResource.class);
attachRoutes(telemetry, router, "/systemInfo", SystemInfoResource.class);
attachRoutes(telemetry, router, "/post", PostResource.class);
attachRoutes(telemetry, router, "/post/{name}", PostResource.class);
attachRoutes(telemetry, router, "/query/{name}", streamResults ? StreamingPostPageQueryResource.class : PostPageQueryResource.class);
attachRoutes(telemetry, router, "/itemImport", ItemImportResource.class);
attachRoutes(telemetry, router, "/stream", StreamResource.class);
String rootPath;
try {
File file = new File(".");
rootPath = file.getCanonicalPath();
} catch (IOException e) {
throw new RuntimeException(e);
}
if(SystemUtils.IS_OS_WINDOWS) {
Directory directory = new Directory(getContext(), new Reference("file:\\\\" + rootPath + "\\images"));
router.attach("/images", directory);
} else {
Directory directory = new Directory(getContext(), new Reference("file://" + rootPath + "/images"));
router.attach("/images", directory);
}
String hostUriForClients = serviceHost + (omitPort ? "" : ":" + servicePort);
final String target = hostUriForClients + "/home";
final Redirector redirector = new Redirector(getContext(), target, Redirector.MODE_CLIENT_TEMPORARY);
router.attach("/", redirector);
return router;
}
Is it possible to capture the request and response body as well within restlet and app insights?
Thanks.
from applicationinsights-java.
@avdhut1990 Could you please create a PR here for a minimal reproducible example with explanations on how to run the example?
from applicationinsights-java.
@avdhut1990
Perhaps you mean that you can see the HTTP requests on Application Insights UI but not their body?
from applicationinsights-java.
Related Issues (20)
- Missing telemetry for LogBook events HOT 2
- Workflow failed: OWASP dependency check (daily) (#372) HOT 3
- Local agent trying to connect to Azure metadata (regression bug?) HOT 2
- Workflow failed: OWASP dependency check (daily) (#376) HOT 85
- Connection string overrides syntax causes Unrecognized field "connectionStringOverrides" configuration error HOT 2
- Query for next expected version of applicationinsights-agent HOT 2
- Agent doesn't detect `connectionString` with configuration file (applicationinsights.json) in default location (same directory as the agent) HOT 4
- Eventgrid Telemetry Correlation HOT 4
- CVE-2023-44487 HOT 4
- Telemetry filters on span events HOT 19
- Telemetry processors bug HOT 16
- Azure Function hosted on Kubernetes does not work HOT 15
- CVE-2023-6378 HOT 10
- Agent not reporting HTTP operations from spring app HOT 7
- Azure Security reports CVE-2018-1000011 HOT 4
- General Availability target for sampling overrides HOT 5
- in the latest JAR 3.4.18, there are two HIGH Vulnerabilities CVE-2023-6378 with ch.qos.logback:logback-classic and ch.qos.logback:logback-core HOT 2
- Classic SDK TelemetryClient not capturing any data HOT 4
- Add ability to disable reactor instrumentation HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from applicationinsights-java.