Skip to content

Conversation

@kavehshahedi
Copy link
Contributor

@kavehshahedi kavehshahedi commented Mar 27, 2025

What it does

Following the introduction of configurable reports data providers, the trace server can now face a new data provider type for report providers (i.e., "MIME"). This commit introduces the required endpoint for fetching the MIME reports from the trace server based on the given configurable output id.

This PR depends on:

  1. tmf: Introduce "MIME" data provider type eclipse-tracecompass/org.eclipse.tracecompass#242
  2. Add data fetching capabilities to data providers eclipse-tracecompass/org.eclipse.tracecompass#251

How to test

In order to fetch a specific image output from the server, you can send a GET request with the following structure:

/tsp/api/experiments/EXP-ID/outputs/report/REPORT-OUTPUT-ID

Follow-ups

  1. Proper unit tests should be implemented
  2. Front-end products should follow this endpoint for fetching the MIME reports

Review checklist

  • As an author, I have thoroughly tested my changes and carefully followed the instructions in this template

Copy link
Contributor

@bhufmann bhufmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MatthewKhouzam
MatthewKhouzam previously approved these changes Apr 10, 2025
Copy link
Contributor

@MatthewKhouzam MatthewKhouzam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

image

You need to add the depends on pull request from mainline.

@kavehshahedi kavehshahedi changed the title server: Add get image data provider endpoint server: Add get report data provider endpoint Apr 10, 2025
return Response.status(Status.NOT_FOUND).entity(NO_SUCH_CONFIGURATION).build();
}

IDataProviderFactory factory = manager.getFactory(REPORTS_FACTORY_ID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint has to be independent of the reports customization. For example, if the incubator analysis.core plug-in not installed, how would one fetch the data of a data provider of type MIME?.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, I tried to decouple this endpoint from REPORTS_FACTORY_ID by using the given output's id in the endpoint. However, the issue is that, except for ReportsDataProviderFactory, no other report data provider classes are inheriting the IDataProviderFactory. Hence, when loading the available factories in the startup, the report-based data providers whose ID is not REPORTS_FACTORY_ID would not be recognized as a factory.

As the ReportsDataProviderFactory class is responsible for handling the entire pipeline of reports, I guess we might need to keep the structure as is. Also, the endpoint is specifically for getting report data, which makes it suitable for using the REPORTS_FACTORY_ID in it, although in some cases, the user might not have installed this plugin.

What do you think of this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REPORTS_FACTORY_ID is only available if the incubator.analysis.core plug-in is installed. Otherwise there can't be any reports create by anything else.

Copy link
Contributor Author

@kavehshahedi kavehshahedi Apr 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that's fine. Since the endpoint is only for this specific DP, in case of missing (e.g., not being installed), we can tell the user that it's not installed as a plug-in. wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that's fine. Since the endpoint is only for this specific DP, in case of missing (e.g., not being installed), we can tell the user that it's not installed as a plug-in. wdyt?

That's not really an option. Users cannot install plug-ins. Trace server applications are pre-build.

@GET
@Path("/report/{outputId}")
@Tag(name = RPT)
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.TEXT_HTML, MediaType.TEXT_PLAIN })
Copy link
Contributor

@bhufmann bhufmann Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In you report related code, you call Files.probeContentType which will return image/jpg (for example). Will that work?

Here is some jersey documentation for @Produces:
https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/user-guide.html#d0e2272

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the MIME type is quite diverse, I have updated the @Produces type to MediaType.WILD_CARD to improve the extendability of this endpoint.

The proper output type (i.e., provided in the response's headers) is then handled by responseModel.getContentType().

return Response.status(Status.NOT_FOUND).entity("Report data model not found").build(); //$NON-NLS-1$
}

return Response.ok(responseModel.getContent(), responseModel.getContentType()).build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For images, responseModel.getContent() returns a object of type File. The content type will be determined by Files.probeContentType() which could return image/jpg or image/svg or if it can't be determined it will be application/octet-stream. I'm clear what will happen in each case and how a FE client can handle that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the endpoint is producing MediaType.WILD_CARD to ensure any MIME data can be handled. The responseModel.getContentType would be responsible for indicating the output type (e.g., image/jpg).
The FE client should handle the output based on the response's headers that indicate the output type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How, will it work? Clients could ask for e.g. applicationt/pdf and the endpoint will allow it because of the wildcard but then the implementation won't be able to create a PDF but an image instead. I'm not clear about the procedure and header negotiation yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, basically, the client can ask only based on the report type. For instance, the client only knows that it's an image, but doesn't know if it's a JPG or PNG or SVG. The endpoint then fetches the DP data, and returns the output with a specific content type, which can be image/jpg or image/png or etc. This information is provided in the response's headers as the content type (I have checked it already).
So, it would be the responsibility of the FE to properly show the image in the output based on the response's content type.

Following the introduction of configurable reports data providers, the trace server
can now face a new data provider type for image providers (i.e., "MIME"). This commit
introduces the required endpoint for fetching the MIME reports from the trace server based on
the given configurable output id.

[Added] A new GET endpoint for MIME report data providers

Signed-off-by: Kaveh Shahedi <kaveh.shahedi@ericsson.com>
* @author Kaveh Shahedi
*/
public class ImageReportDataProvider implements IReportDataProvider {
public class ImageReportDataProvider implements IReportDataProvider, IDataProviderFactory {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A data provider should not be a data provider factory. Generally,, we have data provider factories that create data provider instances which provide data (tree, xy, states, reports data). In this implementation, the reports data provider is a configurator, factory and data provider. The factory's main responsibility to create data providers. It can have the capabilities of a configurator. Using the configurator the data provider factory will be able to create instances of data providers using configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely right. I was working around with this IDataProiderFactory to see how we can solve the manager.getFactory() issue in the DataProviderService class, but I forgot to remove it in the end from the class. I will fix it.

return Response.status(Status.NOT_FOUND).entity(NO_SUCH_TRACE).build();
}

IDataProviderDescriptor descriptor = getDescriptor(experiment, outputId);
Copy link
Contributor

@bhufmann bhufmann Apr 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always return null, because the DataProviderManager doesn't know about the data provider with that ID (unless it was registered). This shows some issue with the DataProviderManager because it manages ITmfTreeDataProviders. So, either the reports data provider implements ITmfTreeDataProvider which is created by the reports data provider factory (not the cleanest implementation), or in Trace Compass mainline the DataProviderManager is updated to handle other data providers than trees or a new data provider manager is created for new types of data providers. Trace Compass designers will have to be involved with this design in Trace Compass core.

We need something like this below:

provider = manager.getOrCreateDataProvider(experiment, outputId, IReportDataProvider.class)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have already tested this endpoint, and I could see that this code block is not returning null in cases where the given output is a valid report DP. It also works fine for cases where the ID of the output is not valid (e.g., not present in the DP manager).

I'm not sure if I have understood your point correctly or not, but please correct me if I'm wrong.


@SuppressWarnings("restriction")
@Override
public TmfModelResponse<TmfDataProviderDataModel<?>> getData(ITmfTrace trace, IDataProviderDescriptor descriptor) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The factory should be responsible create data providers (see line 121 above which needs to be implemented). Then the instance of data provider that was created there needs to be this method getData().

return Response.status(Status.NOT_FOUND).entity(NO_SUCH_CONFIGURATION).build();
}

IDataProviderFactory factory = manager.getFactory(REPORTS_FACTORY_ID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REPORTS_FACTORY_ID is only available if the incubator.analysis.core plug-in is installed. Otherwise there can't be any reports create by anything else.

return Response.status(Status.NOT_FOUND).entity("Report data model not found").build(); //$NON-NLS-1$
}

return Response.ok(responseModel.getContent(), responseModel.getContentType()).build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How, will it work? Clients could ask for e.g. applicationt/pdf and the endpoint will allow it because of the wildcard but then the implementation won't be able to create a PDF but an image instead. I'm not clear about the procedure and header negotiation yet.

@bhufmann
Copy link
Contributor

bhufmann commented May 14, 2025

@kavehshahedi, please pay attention to PR #188 where the o.e.tc.incubator.analysis.* plug-ins are move to the analysis folder, in order to remove the callstack folder after cleaning-up that folder (#185). You will have re-import the plug-ins to your development environment and apply your report related changes there..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants